/*
 * To change this template, choose Tools | Templates
 * AND open the template in the editor.
 */

package modelos;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.LinkedList;
import java.util.LinkedList;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author usuario
 */
public class ModeloOrden extends ModeloDB{

    private String  cedula;
    private float total;

    public ModeloOrden(){
            super();
    }

    public boolean registar(){
        abrirConexion();
        boolean sw = false;
        String tira="INSERT INTO Orden (codigo, cedula, total,estatus) VALUES("+getCodigo()+",'"+getCedula()+"',"+getTotal()+",'A')";
        try {
            Statement stam = conexion.createStatement();
            stam.execute(tira);
            sw= true;
        } catch (SQLException ex) {
                 Logger.getLogger(ModeloProducto.class.getName()).log(Level.SEVERE, null, ex);
       
             sw= false;
        }
        cerrarConexion();
        return sw;
    }


    
    public String getCedula() {
        return cedula;
    }

    public void setCedula(String cedula) {
        this.cedula = cedula;
    }


    public float getTotal() {
        return total;
    }

    public void setTotal(float total) {
        this.total = total;
    }

    public void registarProductos(LinkedList<Integer> codigos, LinkedList<Integer> cantidades) {
        abrirConexion();
        for (int i = 0; i < codigos.size(); i++) {
            String tira="INSERT INTO ProductoXOrden (cod_ord, cod_pro,cantidad) VALUES("+getCodigo()+","+codigos.get(i)+","+cantidades.get(i)+")";
            try {
                Statement stam = conexion.createStatement();
                stam.execute(tira);

            } catch (SQLException ex) {
                Logger.getLogger(ModeloOrden.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        cerrarConexion();
    }



    

    



}
